<?php
use yii\helpers\Html;
use yii\widgets\ActiveForm;
use kartik\file\FileInput;
use yii\helpers\Url;
use yii\helpers\ArrayHelper;
use kartik\markdown\MarkdownEditor;
use kartik\markdown\Markdown;

$this->registerCssFile('@web/css/admin.css');
$this->registerCssFile('@web/css/jquery.dad.css');
$this->registerJsFile('@web/js/jquery.dad.min.js');
?>
<div style="width: 100%;height: 80px;font-size: 25px;  line-height:55px;text-align: center; border: 2px solid salmon ;margin-top:5px" >拖动图片排序</div>
        <div class="DescImages">
            <?php foreach($GoodsDescImages as $k=>$v) {
                $sort = $k+1;
                echo  '<div id="'.$v['goods_desc_images_id'].'" class="item item'.$sort.'">'.
                    "<img width='10%'  src='" .  '../' . $v['goods_desc_image'] . "' class='file-preview-image'>".
                    '</div>';
            }?>
        </div>
        <script>
            $(function(){
                $('.DescImages').dad();
            });
            /**
             * 图片排序Ajax请求
             */
            function toPostAjax(conArray)
            {
                conArray = JSON.stringify(conArray);
                console.log(conArray)
                $.ajax({
                    url: '?r=goods/goods/sort',
                    type: 'post',
                    data: conArray,
                    success: function (data) {
                        // do something
                    }
                });
            }
        </script>